package com.wuxiaofan.ware.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.ware.entity.Purchase;
import com.wuxiaofan.ware.entity.custom.PurchaseCustom;
import com.wuxiaofan.ware.mapper.PurchaseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.ware.client.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class PurchaseService {
    @Autowired
    private PurchaseMapper wmsPurchaseMapper;
    @Resource
    private Idgenerator idgenerator;
    public Purchase findById(String id){
        return wmsPurchaseMapper.selectById(id);
    }

    public PurchaseCustom findCountByMap(Map paraMap){
        return wmsPurchaseMapper.findCountByMap(paraMap);
    }

    public PurchaseCustom findGroupByMap(Map paraMap){
        return wmsPurchaseMapper.findGroupByMap(paraMap);
    }

    public List<PurchaseCustom> findByMap(Map paraMap){
        return wmsPurchaseMapper.findByMap(paraMap);
    }

    public Page<PurchaseCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(wmsPurchaseMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        wmsPurchaseMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        wmsPurchaseMapper.deleteById(id);
    }

    public Purchase save(Purchase wmsPurchase){
        wmsPurchase.setId(idgenerator.getId());
        wmsPurchaseMapper.insert(wmsPurchase);
        return wmsPurchase;
    }

}
